// 读取文件-fs模块

const fs = require('fs')
const path = require('path')

/* fs.readFile(path.join(__dirname,'../../0.filse/test.txt'),(err,data)=>{
  if(err) return console.log('读取文件失败！' + err);

  console.log(data.toString());
}) */

// Promise 封装 

let p = new Promise((resolve, reject) => {
  fs.readFile(path.join(__dirname,'../../0.filse/test.txt'),(err,data)=>{
    if(err) reject(err);

    resolve(data);
  })
})

p.then((value)=>{
  console.log(value.toString())
},(reason)=>{
  console.warn('读取文件失败！' + reason)
})